<?php
class Contorller{
	private  $_db = null;
	
	private   $_view = null;
	
	public $language;
	public $isLogin= false;
	public $userInfo = null;
	public  $layout =null;
	public $request = null;
	public function Contorller(){
		$this->language = Fw::app()->param["language"];
		$this->layout='main';
		$this->userInfo = Fw::app()->getSession("userInfo");
		if(!empty($this->userInfo)) $this->isLogin = true;
		$this->request = $_REQUEST;
		$this->init();
	}
	
	public function init(){
		
	}
	/**
	 * model 类
	 */
	public function db(){
		if(empty($this->_db)){
			$this->_db =  Fw::app()->load("model");
		}
		return $this->_db;
	}
	
	
	/**
	 * 视图 
	 */
	public function view(){
		if(empty($this->_view)){
			$this->_view =  Fw::app()->load("view");
		} 
		return $this->_view;
	}
	
	public function redirect($c,$a){
		$url = Fw::app()->getUrl().'?r='.$c.'/'.$a;
		#echo $url; exit;
		header("Location: {$url}");
			//Fw::app()->run($c,$a);
	}
	
	public function render($view,$data=null){
		$v = $this->view();
		$v->exView($this->layout,$view,$data);
	}
}